uninitialized constant [User]Observer
Reported by Al Arzaga | November 8th, 2009 @ 07:49 PM
So I installed the restful_authenticaiton plugin.
$ script/plugin install restful_authentication
Generated files using "Students" as my model (instead of the often-used "Users"). Note that I've added the --include-activation flag.
$ ./script/generate authenticated students sessions --include-activation
And after editing my environment.rb with the line:
config.active_record.observers = :student_observer # or whatever
you
I get the following output when trying to run script/server
$ ./script/server => Booting WEBrick => Rails 2.3.4
application starting on http://0.0.0.0:3000
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:443:in
load_missing_constant': uninitialized constant
StudentObserver (NameError)
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:80:in `const_missing'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:92:in `const_missing'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/inflector.rb:361:in `constantize'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/inflector.rb:360:in `each'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/inflector.rb:360:in `constantize'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/core_ext/string/inflections.rb:162:in `constantize'
from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/observer.rb:38:in `instantiate_observers'
from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/observer.rb:36:in `each'
from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/observer.rb:36:in `instantiate_observers'
from /Library/Ruby/Gems/1.8/gems/actionpack-2.3.4/lib/action_controller/dispatcher.rb:15:in `define_dispatcher_callbacks'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/callbacks.rb:182:in `call'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/callbacks.rb:182:in `evaluate_method'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/callbacks.rb:166:in `call'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/callbacks.rb:90:in `run'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/callbacks.rb:90:in `each'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/callbacks.rb:90:in `send'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/callbacks.rb:90:in `run'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/callbacks.rb:276:in `run_callbacks'
from /Library/Ruby/Gems/1.8/gems/actionpack-2.3.4/lib/action_controller/dispatcher.rb:51:in `send'
from /Library/Ruby/Gems/1.8/gems/actionpack-2.3.4/lib/action_controller/dispatcher.rb:51:in `run_prepare_callbacks'
from /Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/initializer.rb:631:in `prepare_dispatcher'
from /Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/initializer.rb:185:in `process'
from /Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/initializer.rb:113:in `send'
from /Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/initializer.rb:113:in `run'
from /Users/aarz/Sites/50forthefuture/branches/heroku3/config/environment.rb:9
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in `require'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:521:in `new_constants_in'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in `require'
from /Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/commands/server.rb:84
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
from ./script/server:3
What step might I have missed?
Comments and changes to this ticket
-
Al Arzaga November 8th, 2009 @ 07:50 PM
Sorry, I forgot to add that I'm running Rails 2.3.4 on ruby 1.8.7.
-
Susanna Schroeder December 16th, 2009 @ 04:13 PM
- Tag set to aasm, restful_authentication
I am having the same problem too.
I used --include-activation, --aasm, and --rspec flags.
Are the instructions incorrect? THe
config.active_record.observers = :user_observer
line seems to be for the --stateful option, which is no longer used (replaced by aasm)
Could it be that we should not be including the line in environment.rb anymore?
There certainly is no user_observer.rb in the models directory. After following the instructions.
Anyone?
-
hhcv February 18th, 2010 @ 05:13 PM
I encountered this same problem when editing my environment.rb file to register an observer before having created it.
I simply commented it out, created the observer/installed the plugin, and restarted the server.
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
Restful Authentication Generator
This widely-used plugin provides a foundation for securely managing user
authentication:
* Login / logout
* Secure password handling
* Account activation by validating email
* Account approval / disabling by admin
* Rudimentary hooks for authorization and access control.
http://github.com/technoweenie/restful-authentication/tree